<template>
    <div class="newMessage" style="width: 98%">
        <!-- 查询条件 -->
        <div class="messagebulletin-box">
            <el-form
                :model="dataForm"
                ref="dataForm"
                label-width="100px"
                :disabled="this.see == 1"
                :rules="dataFormRules"
            >
                <el-form-item label="消息标题" prop="messageTitle">
                    <el-input
                        style="width: 30%; float: left"
                        v-model="dataForm.messageTitle"
                        placeholder="请输入消息标题"
                    ></el-input>
                </el-form-item>
                <el-form-item label="消息摘要" prop="summary">
                    <el-input
                        style="width: 30%; float: left"
                        v-model="dataForm.summary"
                        placeholder="请输入消息摘要"
                    ></el-input>
                </el-form-item>
                <el-form-item label="消息内容" prop="messageContent">
                    <tinymce v-model="dataForm.messageContent" :height="300" style="width:90%" />
                </el-form-item>
                <el-form-item label="添加附件" prop="url">
                    <el-upload
                        :action="uploadActionUrl"
                        :before-upload="onBeforeUpload"
                        :on-success="onUploadSuccess"
                        :with-credentials="true"
                        :multiple="false"
                        :limit="1"
                        style="width: 30%; float: left"
                        ref="upload"
                        :file-list="fileList"
                    >
                        <el-button size="small" type="primary">点击上传</el-button>
                    </el-upload>
                </el-form-item>
                <el-form-item label="接收类型" prop="receptionType">
                    <template>
                        <el-radio
                            style="float: left; margin-top: 0.8%"
                            @change="receptionTypeChange"
                            v-model="dataForm.receptionType"
                            label="1"
                        >所有系统后台用户</el-radio>
                        <el-radio
                            style="float: left; margin-top: 0.8%"
                            v-model="dataForm.receptionType"
                            @change="getFontUserList"
                            label="4"
                        >所有前台用户</el-radio>
                        <el-radio
                            style="float: left; margin-top: 0.8%"
                            @change="receptionTypeChange"
                            v-model="dataForm.receptionType"
                            label="3"
                        >分中心用户</el-radio>
                        <el-radio
                            style="float: left; margin-top: 0.8%"
                            @change="receptionTypeChange"
                            v-model="dataForm.receptionType"
                            label="2"
                        >部分系统用户</el-radio>
                        <kt-button
                            :label="$t('添加系统用户')"
                            style="float: left; margin-left: 2%"
                            @change="receptionTypeChange"
                            @click="addUserName"
                            perms="true"
                            type="primary"
                            v-if="dataForm.receptionType == 2 && !this.see"
                        />
                    </template>
                </el-form-item>
                <el-row>
                    <el-col :span="6">
                        <el-form-item v-if="dataForm.receptionType==3" label="业务线">
                            <el-select
                                multiple
                                v-if="dataForm.receptionType==3"
                                v-model="businessTypes"
                                filterable
                                placeholder="请选择业务线"
                                clearable
                                style="width: 100%"
                                @change="businessTypeChange3"
                            >
                                <el-option
                                    v-for="item in studentBusinessType"
                                    :key="item.key"
                                    :label="item.value"
                                    :value="item.key"
                                ></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="6">
                        <el-form-item v-if="dataForm.receptionType==4" label="前台用户类型">
                        <el-select
                            v-if="dataForm.receptionType==4"
                            v-model="fontUserType"
                            filterable
                            multiple
                            placeholder="请选择前台用户类型"
                            clearable
                            value-key="id"
                            style="width: 100%"
                            @change="fontUserTypeChange"
                        >
                            <el-option
                                v-for="item in backOrFrontOption2"
                                :key="item.key"
                                :label="item.value"
                                :value="item.key"
                            ></el-option>
                        </el-select>
                    </el-form-item> 
                    </el-col>
                </el-row>
                <el-form-item label="已选用户" prop="messageSender" v-if="dataForm.receptionType == 2">
                    <kt-table
                        newMessage
                        permsRemove="true"
                        :showBatchDelete="false"
                        :data="pageResults"
                        :columns="columnsCheck"
                        style="width: 80%"
                        @findPage="findPage"
                        @handleRemove="handleRemove"
                    ></kt-table>
                </el-form-item>
                <el-row>
                    <el-col :span="6">
                        <el-form-item label="发布类型" prop="publishType">
                            <el-select
                                v-model="dataForm.publishType"
                                filterable
                                placeholder="请选择发布类型"
                                clearable
                                value-key="key"
                                style="width: 100%"
                            >
                                <el-option
                                    v-for="item in publishType"
                                    :key="item.key"
                                    :label="item.value"
                                    :value="item.key"
                                ></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item label="发布时间" prop="sendDate" v-if="dataForm.publishType == 2">
                            <el-date-picker
                                v-model="dataForm.sendDate"
                                type="datetime"
                                placeholder="选择日期时间"
                                value-format="yyyy-MM-dd HH:mm:ss"
                                format="yyyy-MM-dd HH:mm:ss"
                            ></el-date-picker>
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
            <div class="from-btns">
                <kt-button
                    :label="$t('action.close')"
                    @click="closeSelectedTag()"
                    perms="true"
                    size
                    style="margin-right: 5%"
                />
                <kt-button
                    label="发送"
                    v-if="!this.dataForm.id"
                    @click="saveForm"
                    :loading="editLoading"
                    perms="true"
                    size
                    type="primary"
                />
                <kt-button
                    :label="$t('action.save')"
                    v-if="this.dataForm.id && !this.see"
                    @click="editForm"
                    :loading="editLoading"
                    perms="true"
                    size
                    type="primary"
                />
            </div>
        </div>
        <!--添加系统用户-->
        <el-dialog
            :title="'添加系统用户'"
            width="55%"
            :visible.sync="dialogVisible"
            :close-on-click-modal="false"
        >
            <el-form :model="dataFormAdd" ref="dataFormAdd" :size="size">
                <el-row :gutter="20">
                    <el-col :span="8">
                        <el-form-item prop="userName">
                            <el-input
                                v-model="dataFormAdd.userName"
                                auto-complete="off"
                                placeholder="请输入系统用户名"
                            ></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item prop="realName">
                            <el-input
                                v-model="dataFormAdd.realName"
                                auto-complete="off"
                                placeholder="请输入真实姓名"
                            ></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="9" style="margin-left:0">   
                        <el-col :span="1"><span style="display:inline-block;color: red;margin-top: 8px;">*</span></el-col>
                        <el-col :span="21"> <el-form-item prop="backOrFront">
                            <el-select
                                v-model="dataFormAdd.backOrFront"
                                filterable
                                placeholder="请选择系统用户类型"
                                clearable
                                @change="backOrFrontChange"
                                value-key="id"
                                style="width: 100%"
                            >
                                <el-option
                                    v-for="item in backOrFrontOption"
                                    :key="item.key"
                                    :label="item.value"
                                    :value="item.key"
                                ></el-option>
                            </el-select>
                        </el-form-item></el-col>
                    </el-col>
                    <el-col :span="8" v-if="dataFormAdd.backOrFront==5" style="margin-left:0">
                        <el-form-item prop="threeLevelDeptId">
                            <el-select
                                v-model="dataFormAdd.threeLevelDeptId"
                                filterable
                                placeholder="请输入三级部门"
                                clearable
                                value-key="id"
                                style="width: 100%"
                            >
                                <el-option
                                    v-for="item in deptLevel3"
                                    :key="item.id"
                                    :label="item.deptName"
                                    :value="item.id"
                                ></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8" v-if="dataFormAdd.backOrFront==4" style="margin-left:0">
                        <el-form-item prop="threeLevelDeptId">
                            <el-select
                                v-model="businessTypes"
                                filterable
                                placeholder="请选择业务线"
                                clearable
                                style="width: 100%"
                                @change="businessTypeChange"
                            >
                                <el-option
                                    v-for="item in studentBusinessType"
                                    :key="item.key"
                                    :label="item.value"
                                    :value="item.key"
                                ></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
            <div class="from-btns">
                <kt-button
                    :label="$t('action.reset')"
                    @click="resetForm('dataForm')"
                    perms="true"
                    type="primary"
                />
                <kt-button
                    :label="$t('action.search')"
                    @click="searchForm"
                    :loading="editLoading"
                    perms="true"
                    type="primary"
                />
            </div>
            <!-- <kt-table
                :data="pageResult"
                :columns="columns"
                style="width: 100%"
                @findPage="findPage"
                @selectionChange="selectionChange"
            ></kt-table>-->
            <el-table
                :data="pageResult.content"
                :row-key="getRowKey"
                ref="buyerTable"
                @selection-change="selectionChange"
                style="width: 100%"
            >
                <el-table-column type="selection" width="50" :reserve-selection="true"></el-table-column>
                <el-table-column type="index" label="序号" width="50"></el-table-column>
                <el-table-column prop="userName" :label="backOrFrontUser"></el-table-column>
                <!-- <el-table-column prop="businessType" label="业务线"></el-table-column> -->
                <el-table-column :prop="dataFormAdd.backOrFront==5?'threeDeptName':'businessType'" :label="dataFormAdd.backOrFront==5?'三级部门':'业务线'"></el-table-column>
            </el-table>
            <el-pagination
                @size-change="handleBuyerSizeChange"
                @current-change="handleBuyerCurrentChange"
                :current-page="pageRequest.pageNum"
                :page-size="30"
                layout="total, sizes, prev, pager, next, jumper"
                :total="pageResult.totalSize"
            ></el-pagination>

            <div slot="footer" class="dialog-footer">
                <el-button size="medium" @click.native="dialogVisible = false">
                    {{
                    $t("action.cancel")
                    }}
                </el-button>
                <el-button
                    size="medium"
                    authType="primary"
                    @click.native="submitForm"
                    :loading="editLoading"
                >{{ $t("action.submit") }}</el-button>
            </div>
        </el-dialog>
    </div>
</template>

<script>
import CrmTreeInput from "@/components/CrmTreeInput";
import PopupTreeInput from "@/components/PopupTreeInput";
import KtButton from "@/views/Core/KtButton";
import KtTable from "@/views/Core/KtTable";
import { baseUrl } from "@/utils/global";
import Tinymce from "@/components/Tinymce";
import axios from "axios";
export default {
    name: "NewMessage",
    components: {
        PopupTreeInput,
        KtButton,
        KtTable,
        CrmTreeInput,
        Tinymce
    },
    data() {
        return {
            radio: "1",
            size: "small",
            filters: {
                name: ""
            },
            see: this.$route.query.see, //查看权限
            columns: [
                { type: "index", label: "序号", minWidth: 50 },
                { prop: "userName", label: "用户名", minWidth: 150 },
                { prop: "realName", label: "真实姓名", minWidth: 250 },
                { prop: "threeDeptName", label: "三级部门", minWidth: 250 }
            ],
            columnsCheck: [
                { type: "index", label: "序号", minWidth: 50 },
                { prop: "realName", label: "真实姓名", minWidth: 250 },
                { prop: "businessType", label: "业务线", minWidth: 250 },
                { prop: "threeDeptName", label: "三级部门", minWidth: 250 }
            ],
            pageRequest: { pageNum: 1, pageSize: 10, backOrFront: 1 },
            pageResult: {
                content: [],
                totalSize: ""
            },
            dialogVisible: false, //弹窗
            operation: false, // true:新增, false:编辑
            editLoading: false,
            dataFormRules: {
                messageTitle: [
                    {
                        required: true,
                        message: "请输入消息标题",
                        trigger: "blur"
                    }
                ],
                messageContent: [
                    {
                        required: true,
                        message: "请输入消息内容",
                        trigger: "blur"
                    }
                ],
                summary: [
                    {
                        required: true,
                        message: "请输入消息摘要",
                        trigger: "blur"
                    }
                ],
                publishType: [
                    {
                        required: true,
                        message: "请选择发布类型",
                        trigger: "blur"
                    }
                ],
                backOrFront: [
                    {
                        required: true,
                        message: "请选择发布类型",
                        trigger: "change"
                    }
                ],
            },
            // 界面数据
            dataForm: {
                createDate: "",
                creater: 0,
                id: "",
                messageContent: "",
                messageReceivorList: [],
                messageSender: "",
                messageStatus: "",
                messageTitle: "",
                publishType: "",
                receptionType: "1",
                sendDate: "",
                backOrFront: 1,
                messageUserInput: {
                    frontType: 5
                }
            },
            messageReceivorList: [],
            //新增数据
            dataFormAdd: {
                backOrFront:'',
                threeLevelDeptId:'',
                userName:'',
                realName:'',
            },
            selections: [], //选中列表集合
            deptLevel3: [], // 三级部门下拉框
            backOrFrontOption: [
                // {
                //   value: "后台用户",
                //   key: 1,
                // },
                // {
                //   value: "前台用户",
                //   key: 2,
                // },
            ], //系统消息类型
            backOrFrontOption2: [],
            publishType: [], // 发布类型
            value: "",
            pageResults: {
                content: [],
                totalSize: ""
            }, // 选中用户合集
            messageProps: {
                label: "value",
                children: "children"
            },
            uploadActionUrl: baseUrl + "/mediaInfo/upload", //上传附件接口
            fileList: [],
            studentBusinessType: [],
            businessTypes: "",
            fontUserType: "",
            backOrFrontUser:'用户名'
        };
    },
    methods: {
        //获取数据
        getParams() {
            this.studentBusinessType = JSON.parse(
                localStorage.getItem("studentBusinessType")
            );
            // 取到路由带过来的参数
            let routerParams = this.$route.query.id;
            // 将数据放在当前组件的数据内
            if (routerParams) {
                this.$api.message
                    .queryMessageById({ messageId: routerParams })
                    .then(res => {
                        this.dataForm = Object.assign({}, res.systemMessage);
                        this.dataForm.receptionType = res.systemMessage.receptionType.toString();
                        if (res.systemMessage.url != null) {
                            this.fileList = [
                                {
                                    name: res.systemMessage.fileName,
                                    url: res.systemMessage.url
                                }
                            ];
                        }
                    });
            }
        },
        //获取下拉列表
        findDown: function() {
            this.$api.dropdown.deptLevel3().then(res => {
                this.deptLevel3 = res.departmentInfoList;
            });
            this.$api.dropdown.publishType().then(res => {
                this.publishType = res.keyValueList;
            });
        },
        // 下拉框选中选中
        handleTreeSelectChange(data, node) {
            this.dataForm.publishType = data.key;
            this.value = data.value;
        },
        //表单重置
        resetForm() {
            this.dataFormAdd.backOrFront=''
            this.dataFormAdd.threeLevelDeptId=''
            this.dataFormAdd.userName=''
            this.dataFormAdd.realName=''
            this.businessTypes=''
            this.dataFormAdd.businessType=''
            this.editLoading = false;
            this.columns[3].label = "三级部门";
            this.pageRequest.backOrFront = 1;
            this.pageRequest.pageNum = 1;
            if (this.selections.length > 0) {
                this.$refs.buyerTable.clearSelection();
            }
            this.findPage(null);
        },
        // 添加系统用户
        addUserName() {
            this.dialogVisible = true;
            this.pageRequest.pageNum = 1;
            this.findPage(null);
            if (this.selections.length > 0) {
                this.$refs.buyerTable.clearSelection();
            }
            // 获取业务线
            this.studentBusinessType = JSON.parse(
                localStorage.getItem("studentBusinessType")
            );
            this.$api.user
                .optionsList({ codeType: "message_search_type" })
                .then(res => {
                    if (res.result == 1) {
                        this.backOrFrontOption = res.keyValueList;
                    } else {
                        this.$message.error(res.msg);
                    }
                });
            // this.pageResults.content.length=0
        },
        // 获取前台系统用户
        getFontUserList() {
            this.businessTypes=''
            this.fontUserType=''
            this.$api.user
                .optionsList({ codeType: "message_search_type" })
                .then(res => {
                    if (res.result == 1) {
                        for (var i = 0; i < res.keyValueList.length; i++) {
                            if (res.keyValueList[i].value == "分中心") {
                                res.keyValueList.splice(i, 1);
                            }
                            if (res.keyValueList[i].value == "总部用户") {
                                res.keyValueList.splice(i, 1);
                            }
                        }
                        this.backOrFrontOption2 = res.keyValueList;
                    } else {
                        this.$message.error(res.msg);
                    }
                });
        },
        // 获取分页数据
        findPage: function(data) {
            //
            if (data !== null) {
                data.pageRequest.backOrFront = 1;

                this.pageRequest = data.pageRequest;
                this.pageRequest = Object.assign({}, this.pageRequest);
            }
            this.pageRequest.columnFilters = {
                name: { name: "name", value: this.filters.name }
            };

            this.$api.message
                .unionUserList({ ...this.pageRequest, ...this.dataFormAdd })
                .then(res => {
                    this.pageResult.content = res.userInfoList;
                    this.pageResult.totalSize = res.total;
                    this.pageResults.content = this.dataForm.messageReceivorList;
                    this.pageResults.totalSize = this.dataForm.messageReceivorList.length;
                })
                .then(data != null ? data.callback : "");
        },
        receptionTypeChange(params) {
            this.businessTypes=''
            this.fontUserType=''
        },
        // 移除
        handleRemove: function(data) {
            for (let i = 0; i < this.dataForm.messageReceivorList.length; i++) {
                if (data.row.id == this.dataForm.messageReceivorList[i].id) {
                    this.dataForm.messageReceivorList.splice(i, 1);
                }
            }
        },
        //查询
        searchForm: function() {     
            if(this.dataFormAdd.backOrFront==''){
                this.$message({ message: '请选择系统用户类型！', type: 'error' });
                return false
            }
            if (this.dataFormAdd.backOrFront == 4) {
                this.columns[3].label = "业务线";
                this.columns[3].prop = "businessType";
            } else {
                this.columns[3].label = "三级部门";
                this.columns[3].prop = "threeDeptName";
            }
            this.$refs.dataFormAdd.validate(valid => {
                if (valid) {
                    this.editLoading = true;

                    this.pageRequest.backOrFront = this.dataFormAdd.backOrFront;
                    let params = Object.assign(
                        {},
                        this.dataFormAdd,
                        this.pageRequest
                    );

                    this.$api.message.unionUserList(params).then(res => {
                        this.editLoading = false;
                        if (res.errorCode == 0) {
                            this.pageResult.content = res.userInfoList;
                            this.pageResult.totalSize = res.total;
                        }
                    });
                }
            });
        },
        handleBuyerSizeChange(pageSize) {
            this.pageRequest.pageSize = pageSize;
            this.findPage(null);
        },
        handleBuyerCurrentChange(pageNum) {
            this.pageRequest.pageNum = pageNum;
            this.findPage(null);
        },
        // 获取选中的表格数据
        selectionChange: function(selections) {
            this.selections = selections;
        },
        // 获取选中数据
        submitForm: function() {
            let usersmsg = this.selections.map(item => item);
            usersmsg.forEach(item => {
                item.deptName = item.threedeptName;
                item.userId = item.id;
            });
            let array1 = this.dataForm.messageReceivorList;
            let array2 = usersmsg;
            array1 = array1.filter(
                ({ userName }) =>
                    !array2.some(item => item.userName === userName)
            );
            this.dataForm.messageReceivorList = array1.concat(array2);

            this.findPage(null);
            this.dialogVisible = false;
            this.dataForm.backOrFront = 2;
        },
        //保存
        saveForm: function() {
            // 修改保存业务逻辑
            // 提交json新增messageUserInput对象
            // messageUserInput:{businessType:1=>业务类型, frontType:1.三方  2.学校 3. 分中心子账号 4.分中心账号登录 5.总部账号}
            // 如果选择所有用户messageUserInput必传 frontType：5 所有总部用户
            // 如果选择了部分系统用户 messageUserInput 不用传
            //如果选择了分中心用户 messageUserInput必传 businessType 业务线必传  frontType非必
            //
            // this.dataForm.messageUserInput.businessType=this.dataForm.businessType
            // backOrFront:1后端消息  2：前端消息
            if(this.dataForm.receptionType==3&&this.businessTypes==''){
                this.$message({ message: '请选择业务线', type: 'error' });
                return false
            }
            if(this.dataForm.receptionType==4&this.fontUserType==''){
                this.$message({ message: '请选择用户类型', type: 'error' });
                return false
            }
            this.$refs.dataForm.validate(valid => {
                if (valid) {
                    this.$confirm("确认提交吗？", "提示", {}).then(() => {
                        this.editLoading = true;

                        let params = Object.assign({}, this.dataForm);
                        this.$api.message.save(params).then(res => {
                            if (res.result == 1) {
                                this.$message({
                                    message: res.msg,
                                    type: "success"
                                });
                                this.$refs["dataForm"].resetFields();
                                this.value = "";
                                this.editLoading = false;
                                this.closeSelectedTag();
                                this.dataForm.backOrFront = 1;
                            } else {
                                this.$message({
                                    message: res.msg,
                                    type: "error"
                                });
                                this.editLoading = false;
                            }
                        });
                    });
                }
            });
        },
        //编辑
        editForm: function() {
            this.$refs.dataForm.validate(valid => {
                if (valid) {
                    this.$confirm("确认提交吗？", "提示", {}).then(() => {
                        this.editLoading = true;
                        let params = Object.assign({}, this.dataForm);
                        this.$api.message.edit(params).then(res => {
                            if (res.result == 1) {
                                this.$message({
                                    message: res.msg,
                                    type: "success"
                                });
                                // this.$refs["dataForm"].resetFields();
                                // this.value="";
                                this.editLoading = false;
                            } else {
                                this.$message({
                                    message: res.msg,
                                    type: "error"
                                });
                            }
                        });
                    });
                }
            });
        },
        //路由跳转关闭当前路由
        isActive(route) {
            return route.path === this.$route.path;
        },
        closeSelectedTag(view) {
            this.$store.dispatch("delVisitedViews", this.$route).then(views => {
                if (this.isActive(this.$route)) {
                    const latestView = views.slice(-1)[0];
                    if (latestView) {
                        this.$router.push(latestView);
                    } else {
                        this.$router.push("/");
                    }
                }
            });
        },
        onBeforeUpload(file) {
            const isLt2M = file.size / 1024 / 1024 <= 100; //这里做文件大小限制
            if (!isLt2M) {
                this.$message({
                    message: "上传文件大小不能超过 100MB!",
                    type: "warning"
                });
                return false;
            } else {
            }
        },
        onUploadSuccess(data) {
            this.dataForm.url = data.msg;
        },
        businessTypeChange(params) {
            //

            this.dataFormAdd.businessType = params.toString();
        },
        businessTypeChange2(params) {
            //
            this.dataForm.backOrFront = 2; //发消息类型 给前台用户发
            this.dataFormAdd.backOrFront = 4;
            this.dataFormAdd.businessType = params.toString();
            this.pageRequest.backOrFront = this.dataFormAdd.backOrFront;
            this.pageRequest.pageSize = 9999999;
            let params2 = Object.assign({}, this.dataFormAdd, this.pageRequest);

            this.$api.message.unionUserList(params2).then(res => {
                this.editLoading = false;
                if (res.errorCode == 0) {
                    this.pageResult.content = res.userInfoList;
                    this.pageResult.totalSize = res.total;
                    this.dataForm.messageReceivorList = res.userInfoList;
                }
            });
        },
        businessTypeChange3(params) {
            this.dataForm.backOrFront = 2; //发消息类型 给前台用户发
            this.dataForm.businessType = params.toString();
            let messageUserInput = {
                businessType: "",
                frontType: ""
            };
            // 修改保存业务逻辑
            // 提交json新增messageUserInput对象
            // messageUserInput:{businessType:1=>业务类型, frontType:1.三方  2.学校 3. 分中心子账号 4.分中心账号登录 5.总部账号}
            // frontType：如果选择了全部 必传，如果选择了部分就不用传这个参数
            messageUserInput.businessType = params.toString();
            messageUserInput.frontType = 4;
            this.dataForm.messageUserInput = messageUserInput;
        },
        fontUserTypeChange(params) {
            this.dataForm.backOrFront = 2; //发消息类型 给前台用户发
            let messageUserInput = {
                frontType: ""
            };
            // 修改保存业务逻辑
            // 提交json新增messageUserInput对象
            // messageUserInput:{businessType:1=>业务类型, frontType:1.三方  2.学校 3. 分中心子账号 4.分中心账号登录 5.总部账号}
            // frontType：如果选择了全部 必传，如果选择了部分就不用传这个参数
            messageUserInput.frontType = params.toString();
            this.dataForm.messageUserInput = messageUserInput;
        },
        getRowKey(row) {
            return row.id;
        },
        backOrFrontChange(val){
            if(val==1){
                this.backOrFrontUser='三方姓名'
            }
            if(val==2||val==3){
                this.backOrFrontUser='账户名'
            }
            if(val==4){
                this.backOrFrontUser='分中心编码'
            }
            if(val==5){
                this.backOrFrontUser='用户名'
            }
        }
    },
    mounted() {
        this.findDown();
        this.getParams();
        this.pageResults.content = [];
    },
    watch: {
        // $route(to, from) {
        //   this.dataForm = {
        //     createDate: "",
        //     creater: 0,
        //     id: "",
        //     messageContent: "",
        //     messageReceivorList: [],
        //     messageSender: "",
        //     messageStatus: "",
        //     messageTitle: "",
        //     publishType: "",
        //     receptionType: "1",
        //     sendDate: "",
        //     backOrFront: 1,
        //   };
        //   this.dataFormAdd = {};
        //   this.$refs.upload.clearFiles();
        //   this.getParams();
        // },
    }
};
</script>

<style lang='scss' scoped>
.messagebulletin-box {
    overflow: hidden;
    width: 98%;
    margin: 0 auto;
}
</style>
<style>
.newMessage .el-dialog__wrapper .el-form-item__content {
    margin-left: 0;
}
</style>
